import TurndownService from 'turndown';

class MarkdownService {
    mdToHtml(content: string) {
    }

    htmlToMd(content: string) {
        const turndownService = new TurndownService()
        return turndownService.turndown(content)
    }

    simpleHtml(content: string) {
        const regex = /<([^>\s]+)([^>]+)>(?:.*?)<\/\1>/g;
        let match,
            contentRet = content;
        while ((match = regex.exec(content)) !== null) {
            const attr = match[2];
            contentRet = contentRet.replace(attr, '');
        }
        return contentRet;
    }
}


const markdownService = new MarkdownService();
export default markdownService;
